All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----sun.security.x509.CertAndKeyGen
This provides some simple certificate management functionality. Specifically, it allows you to create self-signed X.509 certificates as well as PKCS 10 based certificate signing requests.
Keys for some public key signature algorithms have algorithm parameters, such as DSS/DSA. Some sites' Certificate Authorities adopt fixed algorithm parameters, which speeds up some operations including key generation and signing. At this time, this interface does not provide a way to provide such algorithm parameters, e.g. by providing the CA certificate which includes those parameters.
Also, note that at this time only signature-capable keys may be acquired through this interface. Diffie-Hellman keys, used for secure key exchange, may be supported later.
public CertAndKeyGen(String keyType, String sigAlg) throws NoSuchAlgorithmException
public void setRandom(SecureRandom generator)
public void generate(int keyBits) throws InvalidKeyException
Note that not all values of "keyBits" are valid for all algorithms, and not all public key algorithms are currently supported for use in X.509 certificates. If the algorithm you specified does not produce X.509 compatible keys, an invalid key exception is thrown.
public X509Key getPublicKey()
public PrivateKey getPrivateKey()
Be extremely careful when handling private keys. When private keys are not kept secret, they lose their ability to securely authenticate specific entities ... that is a huge security risk!
public X509Cert getSelfCert(X500Name myname, long validity) throws InvalidKeyException, SignatureException, NoSuchAlgorithmException
Such certificates normally are used to identify a "Certificate Authority" (CA). Accordingly, they will not always be accepted by other parties. However, such certificates are also useful when you are bootstrapping your security infrastructure, or deploying system prototypes.
public PKCS10 getCertRequest(X500Name myname) throws InvalidKeyException, SignatureException
PKCS10.print
or PKCS10.toByteArray
operations on the result, to get the request in an appropriate
transmission format.
PKCS #10 certificate requests are sent, along with some proof of identity, to Certificate Authorities (CAs) which then issue X.509 public key certificates.
All Packages Class Hierarchy This Package Previous Next Index